using UnityEngine;

public class PartCheckCollision : MonoBehaviour
{
	public bool isGrounded;

	public Vector3 collisionPosition;

	private bool JustSwitched;

	[SerializeField]
	private CharacterInformation info;

	[SerializeField]
	private bool isVitalPart;

	private void Start()
	{
		isVitalPart = true;
	}

	private void FixedUpdate()
	{
		if (!JustSwitched)
		{
			isGrounded = false;
		}
		else
		{
			JustSwitched = false;
		}
	}

	private void Collide(Collision collision)
	{
		if (collision.gameObject.CompareTag("Ground") && !(Vector3.Angle(Vector3.up, collision.contacts[0].normal) > 95f))
		{
			if (Vector3.Angle(Vector3.up, collision.contacts[0].normal) > 75f)
			{
				info.sinceWall = 0f;
				info.wallNormal = collision.contacts[0].normal;
			}
			else
			{
				JustSwitched = true;
				isGrounded = true;
				collisionPosition = collision.contacts[0].point;
			}
		}
	}

	private void OnCollisionEnter(Collision collision)
	{
		Collide(collision);
	}

	private void OnCollisionStay(Collision collision)
	{
		Collide(collision);
	}
}
